﻿@{
    ViewBag.Title = "常用资源管理";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}


<div class="index_lr">
    <div class="index_lrA_title ui-icons">
        <h3>常用资源管理</h3>
    </div>
    <div class="index_pt_bg">
        
        <form action="@Url.Content("~/ComResource/Admin")" method="POST" id="documentform" enctype="multipart/form-data">
        <label>名称:</label>
        <input type="text" name="name" id="name" />
        <label>关键字:</label>
        <input type="text" name="keywords" id="keywords" />
        <label>文件:</label>
        <input type="file" name="mydoc" id="mydoc" />
        <input type="submit" name="submit" value="上传" />
        </form>
    </div>
    <div class="index_lrA_title ui-icons">
    </div>
    <div class="index_pt_bg" id="ListDocuments">
    </div>
</div>


@section ScriptAndCss{
    <link href="../../Content/css/bsadmin.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function loadList() {
            $("#ListDocuments").load("@Url.Action("ListAdmin", "ComResource")", function () {
                $(".deleteDoc", "#ListDocuments").click(function (e) {
                    var isContinue = confirm("你确定要删除这个文件吗？");
                    if (isContinue) {
                        $.post("@Url.Action("Delete", "ComResource")", { id: $(this).attr("data-id") }, function () {
                            loadList();
                            alert("删除成功");
                            location.reload();
                        });
                    }
                    e.preventDefault();
                });
            });
        }

        $(document).ready(function () {
            
            loadList();

            $("#documentform").submit(function () {
                var name = $("#name").val();
                var document1 = $("#mydoc").val();
                var keywords = $("#keywords").val();
                if (name == "" || document1 == "" || keywords == "") {
                    alert("名称,关键字或文件为空，请输入或选择!");
                    return false;
                }
            });
        });

    </script>
}
